{
	template:`
    <m-page @back="back" :title="title">
        <m-top></m-top>
        <m-title>{{title}}
			<template #action>
				<m-button @click="openDetail({beforeLevel:{},afterLevel:{},status:'Y'})">新增</m-button>
			</template>
        </m-title>
		<m-top></m-top>
		<m-list ref="list" :url="url" :params="params" :bottom="0" :search="search">
			<template #item="{item}">
				<m-card join @click="openDetail(item)">
					<div class="flex padding-sm align-center">
						<div class="flex-sub padding-right-sm">
						    <div class="flex align-center">
                                <div class="cu-tag radius" :class="'bg-'+item.beforeLevel.color">{{item.beforeLevel.name}}</div>
                                <div class="padding-lr-xs text-bold text-lg">→</div>
                                <div class="cu-tag radius" :class="'bg-'+item.afterLevel.color">{{item.afterLevel.name}}</div>
                            </div>
                            <div v-if="item.remark" class="text-sm text-grey padding-top-xs">{{item.remark}}</div>
						</div>
					    <div v-if="item.status=='Y'" class="text-right text-blue">
						    <div>消费金额≥{{formatAmount(item.useMoney)}}</div>
						    <div>订单数≥{{formatNum(item.orderNum)}}</div>
					    </div>
					    <status v-else :value="item.status"/>
					</div>
				</m-card>
			</template>
		</m-list>
		<m-modal ref="detail" title="会员升级规则" @close="$refs.list.refresh()">
			<div v-if="showDetail">
				<m-card>
                    <div class="cu-form-group">
                        <div class="title">当前会员</div>
                        <div v-if="showDetail.beforeLevel.oid" class="flex-sub">{{showDetail.beforeLevel.name}} {{'优惠'+formatNum(showDetail.beforeLevel.discount)}}%</div>
                        <div v-else class="flex-sub text-placeholder">请选择当前会员</div>
                        <m-button @click="selectLevel(showDetail,'beforeLevel')" size="sm">选择</m-button>
                    </div>
                    <div class="cu-form-group">
                        <div class="title">升级后会员</div>
                        <div v-if="showDetail.afterLevel.oid" class="flex-sub">{{showDetail.afterLevel.name}} {{'优惠'+formatNum(showDetail.afterLevel.discount)}}%</div>
                        <div v-else class="flex-sub text-placeholder">请选择升级后会员</div>
                        <m-button @click="selectLevel(showDetail,'afterLevel')" size="sm">选择</m-button>
                    </div>
                    <div class="cu-form-group">
                        <div class="title">备注</div>
                        <m-input type="textarea" v-model="showDetail.remark" placeholder="请输入备注"></m-input>
                    </div>
				</m-card>
				<m-title>满足条件
				    <template #action>
				        <m-switch v-model="showDetail.status"></m-switch>
				    </template>
				</m-title>
				<m-card>
                    <div class="cu-form-group">
                        <div class="title">消费金额≥</div>
                        <m-input-number v-model="showDetail.useMoney" placeholder="请输入消费金额"></m-input-number>
                        <div>元</div>
                    </div>
                    <div class="cu-form-group">
                        <div class="title">订单数≥</div>
                        <m-input-number v-model="showDetail.orderNum" placeholder="请输入订单数" format="#,##0"></m-input-number>
                        <div>单</div>
                    </div>
				</m-card>
                <div class="flex padding-lr-sm padding-bottom">
                    <div class="flex-sub flex flex-direction padding-lr-xs">
                        <m-button @click="closeDetail()" line>关闭</m-button>
                    </div>
                    <div class="flex-sub flex flex-direction padding-lr-xs">
                        <m-button @click="save">保存</m-button>
                    </div>
                </div>
			</div>
		</m-modal>
    </m-page>
	`,
	props: ['param','parentVue'],
	data:function(){
		return {
            title:'会员升级配置',
            url:'action/base/levelUpSet/getList',
            params:{},
            search:[
            ],
            showDetail:null
		};
	},
	mounted(){
	},
	methods:{
        openDetail:function(item){
            this.showDetail=Object.assign({},item);
            this.$refs.detail.open();
        },
        closeDetail:function(){
            this.$refs.detail.close();
        },
        selectLevel:function(model,field){
            let selectOid=model[field]?model[field].oid:'';
	        this.openPage('common/selectLevel.js',{title:'选择会员级别',selectOid:selectOid},(flag,obj)=>{
	            if(flag){
	                model[field]=obj;
                }
	        });
        },
        save:function(){
            this.requestData('action/base/levelUpSet/save',
                {model:this.showDetail},
                (data)=>{
                    if(data.code==0){
                        this.remind().success(data.msg);
                        this.closeDetail();
                    }else{
                        this.remind().error(data.msg);
                    }
                }
            );
        }
	}
}